package com.renbang.action.devoloper;


import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.renbang.model.common.AjaxResult;
import com.renbang.utils.WebxmlUtils;
import com.renbang.utils.drawandindex.Higlight;
import com.renbang.utils.drawandindex.Word;
@Controller
@RequestMapping(value = "developer/jiasnhu")
public class JianShuAction {
	
	@RequestMapping(value = "/search")
	public String searchWord(String title, HttpServletRequest request) {
		try {
			request.setAttribute("serchword",title);
			List<Word> list = Higlight.MultiFieldQuery(title);
			request.setAttribute("list",list);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "developer/search-form";
	}
	
	@RequestMapping(value = "/showArticle")
	public String showArticle(String aticleId, HttpServletRequest request) {
		try {
			Word article = Higlight.searchIdIndex("aticleId", aticleId);
			request.setAttribute("article",article);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "developer/search-content";
	}
	/**
	 * 
	 * @Description:天气预报查询
	 * @author:user
	 * @param cityName
	 * @return AjaxResult
	 * @date 2017年5月4日
	 */
	@RequestMapping(value = "/showWeather")
	public @ResponseBody AjaxResult showWeather(String cityName, HttpServletRequest request) {
		System.out.println(cityName);
		String str = null;
		try {
			str = WebxmlUtils.getWeather(cityName);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new AjaxResult(AjaxResult.STATUS_OK, str);
	}
	/**
	 * 
	 * @Description:号码归属地查询
	 * @author:user
	 * @param mobileCode
	 * @return AjaxResult
	 * @date 2017年5月4日
	 */
	@RequestMapping(value = "/showMobileCodeInfo")
	public @ResponseBody AjaxResult showMobileCodeInfo(String mobileCode, HttpServletRequest request) {
		System.out.println(mobileCode);
		String str = null;
		try {
			str = WebxmlUtils.getMobileCodeInfo(mobileCode);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new AjaxResult(AjaxResult.STATUS_OK, str);
		
	}
	
}
